﻿// basetool_demo.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include "SLT_tool_pub.h"
#include "SL_asynFramePub.h"


class clientSession : public SLF_SessionBase
{
public:
    virtual void OnStart() {
        SLT_LOG_ERR("clientSession OnStart====");
        setTimer(1, 1000, false);
    }
    virtual void OnStop() {
        SLT_LOG_ERR("clientSession OnStop====");
    }
    virtual void OnMsgArrive(SLF_senderPtr& _sender, uint32_t srcSid, int msgid, SLF_sendMemBasePtr& _data) {

    }
    virtual void OnTimer(uint32_t timerID, int _intervalMs, bool periodic) {
        SLT_LOG_ERR("clientSession OnTimer");
        setTimer(1, 1000, false);

        static int s_runCount = 0;
        s_runCount++;
        //运行10次后结束
        if (s_runCount >= 5) {
            SLF_delSession(getSessID());
        }
       
    }
};
typedef std::shared_ptr< clientSession>  clientSessionSptr;

int main()
{
    SLT_logInit();
    SLF_init(1);
    
    clientSessionSptr clinetSptr = std::make_shared<clientSession>();
    SLF_addSession(clinetSptr);

    //sl_createTcpServer
    printf("press enter exit\n");
    getchar();
}

